﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:lc="clr-namespace:SocketChat.control"
    mc:Ignorable="d"
            x:Class="SocketChat.MainPage"
             Height="Auto"
             Width="Auto" SizeChanged="UserControl_SizeChanged">
    <Grid x:Name="LayoutRoot" Margin="5"  Background="Gray" ShowGridLines="False">

        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="*" MinHeight="150"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="500"/>
            <ColumnDefinition Width="210"/>
        </Grid.ColumnDefinitions>
        <StackPanel x:Name="spServer" Orientation="Horizontal" Margin="10,10,10,0" Background="White" VerticalAlignment="Top" d:LayoutOverrides="VerticalMargin" Height="30">
            <TextBlock Text="服务器IP：" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0"/>
            <TextBox x:Name="txtServerIP" Width="100" Text="task.24city.com" Height="22" VerticalAlignment="Center" HorizontalAlignment="Center" />
            <Button x:Name="btnSetServer" Content="连 接" Width="60" Margin="5,0,0,0" Height="22" Click="btnSetServer_Click" VerticalAlignment="Center" HorizontalAlignment="Center"  />
            <Button x:Name="btnClose" Content="断 开" Width="60" Margin="5,0,0,0" Height="22" Click="btnClose_Click"  VerticalAlignment="Center" HorizontalAlignment="Center"  />
            <Button x:Name="btnClear" Content="清空聊天记录" Width="80" Margin="5,0,0,0" Height="22" Click="btnClear_Click"   VerticalAlignment="Center" HorizontalAlignment="Center"     />
            <Button x:Name="btnRefresh" Content="刷新页面" Width="60" Margin="5,0,0,0" Height="22" Click="btnRefresh_Click"   VerticalAlignment="Center" HorizontalAlignment="Center"     />

            <TextBlock Text="注：此示例仅为演示，测试图片/文件发送，建议控制在100k以下" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="#FFF70F0F" />
        </StackPanel>
        <ScrollViewer x:Name="scrollChat" VerticalScrollBarVisibility="Auto" Background="White" Grid.Row="1" Margin="10,0">
            <ListBox x:Name="lstChat" ScrollViewer.VerticalScrollBarVisibility="Auto"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0"/>
        </ScrollViewer>

        <StackPanel x:Name="spSend" Orientation="Horizontal" Margin="5,0,5,6" VerticalAlignment="Bottom" Grid.Row="2" Grid.ColumnSpan="2">
            <TextBox x:Name="txtName" Margin="5" Width="80" MaxLength="50" />
            <TextBlock Text="对" VerticalAlignment="Center" Foreground="White"></TextBlock>
            <ComboBox x:Name="cboTarget" Height="24" Margin="3,0" Width="90" SelectionChanged="cboTarget_SelectionChanged" >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding NickName}" ToolTipService.ToolTip="{Binding EndPoint}"></TextBlock>
                    </DataTemplate>
                </ComboBox.ItemTemplate>               
            </ComboBox>
            <TextBlock Text="说：" VerticalAlignment="Center" Foreground="White"></TextBlock>
            <TextBox x:Name="txtInput" Margin="5" Width="300" KeyDown="txtInput_KeyDown" MaxLength="10000" />
            <lc:ColorSelect x:Name="colorSelect" Margin="0,0,5,0"></lc:ColorSelect>
			<Border Width="20" Height="20" Margin="0,0,5,0" x:Name="bdrInk" Background="White" Cursor="Hand" ToolTipService.ToolTip="手写板" MouseLeftButtonDown="bdrInk_MouseLeftButtonDown">
				<TextBlock Text="手" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
			</Border>
			
			<Image Height="21" Width="23" Source="img/logo.png" Stretch="Fill" x:Name="imgCapture" Cursor="Hand" Margin="0,0,3,0" ToolTipService.ToolTip="截屏(需要ActiveX支持)" MouseLeftButtonDown="imgCapture_MouseLeftButtonDown"/>
            <CheckBox Content="私聊" x:Name="chkSingle" VerticalAlignment="Center" Foreground="White"></CheckBox>
            <Button x:Name="btnSendMsg" Margin="5" Width="50" Content="发消息" Click="btnSendMsg_Click"/>
            <Button x:Name="btnSendImg" Margin="5" Width="50" Content="发图片" Click="btnSendImg_Click"/>
            <Button x:Name="btnSendFile" Margin="5" Width="50" Content="传文件" Click="btnSendFile_Click"/>
            <TextBlock x:Name="txtAuthor" Text="by:菩提树下的杨过" VerticalAlignment="Center" Foreground="White" Cursor="Hand" MouseLeftButtonDown="txtAuthor_MouseLeftButtonDown">

            </TextBlock>
            
        </StackPanel>

        <StackPanel Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Margin="0,10,10,0">
            <Grid x:Name="gPhoto" Height="150" Background="White">
                <Image x:Name="photo" Source="img/self.png" Stretch="None" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,5,0,0"/>
                <TextBlock Text="菩提树下的杨过" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,3" MouseLeftButtonDown="txtAuthor_MouseLeftButtonDown" Cursor="Hand"></TextBlock>
            </Grid>


            <ListBox x:Name="lstOnline" Margin="0,10,0,0"  MinHeight="100" SelectionChanged="lstOnline_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding NickName}" ToolTipService.ToolTip="{Binding EndPoint}"></TextBlock>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>

    </Grid>
</UserControl>
